package com.xia.service.impl;

import com.xia.mapper.PermissionMapper;
import com.xia.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class PermissionServiceImpl implements PermissionService {

    @Autowired
    private PermissionMapper permissionMapper;

    @Override
    @Transactional // （参与者服务）只需开启本地事务
    public int bindDefaultRole(Long userId) {
        return permissionMapper.bindDefaultRole(userId);
    }

    @Override
    @Transactional // （参与者服务）只需开启本地事务
    public String getUserRoleCode(Long userId) {
        return permissionMapper.getUserRoleCode(userId);
    }

    @Override
    @Transactional // （参与者服务）只需开启本地事务
    public int upgradeToAdmin(Long userId) {
        return permissionMapper.upgradeToAdmin(userId);
    }

    @Override
    @Transactional // （参与者服务）只需开启本地事务
    public int downgradeToUser(Long userId) {
        return permissionMapper.downgradeToUser(userId);
    }
}
